// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <LineGlyphAttributes.h>
#include <DataNode.h>

//
// Enum conversion methods for LineGlyphAttributes::LineType
//

static const char *LineType_strings[] = {
"Line", "Tube", "Ribbon"
};

std::string
LineGlyphAttributes::LineType_ToString(LineGlyphAttributes::LineType t)
{
    int index = int(t);
    if(index < 0 || index >= 3) index = 0;
    return LineType_strings[index];
}

std::string
LineGlyphAttributes::LineType_ToString(int t)
{
    int index = (t < 0 || t >= 3) ? 0 : t;
    return LineType_strings[index];
}

bool
LineGlyphAttributes::LineType_FromString(const std::string &s, LineGlyphAttributes::LineType &val)
{
    val = LineGlyphAttributes::Line;
    for(int i = 0; i < 3; ++i)
    {
        if(s == LineType_strings[i])
        {
            val = (LineType)i;
            return true;
        }
    }
    return false;
}

//
// Enum conversion methods for LineGlyphAttributes::EndPointStyle
//

static const char *EndPointStyle_strings[] = {
"None", "Spheres", "Cones"
};

std::string
LineGlyphAttributes::EndPointStyle_ToString(LineGlyphAttributes::EndPointStyle t)
{
    int index = int(t);
    if(index < 0 || index >= 3) index = 0;
    return EndPointStyle_strings[index];
}

std::string
LineGlyphAttributes::EndPointStyle_ToString(int t)
{
    int index = (t < 0 || t >= 3) ? 0 : t;
    return EndPointStyle_strings[index];
}

bool
LineGlyphAttributes::EndPointStyle_FromString(const std::string &s, LineGlyphAttributes::EndPointStyle &val)
{
    val = LineGlyphAttributes::None;
    for(int i = 0; i < 3; ++i)
    {
        if(s == EndPointStyle_strings[i])
        {
            val = (EndPointStyle)i;
            return true;
        }
    }
    return false;
}

//
// Enum conversion methods for LineGlyphAttributes::SizeType
//

static const char *SizeType_strings[] = {
"Absolute", "FractionOfBBox"};

std::string
LineGlyphAttributes::SizeType_ToString(LineGlyphAttributes::SizeType t)
{
    int index = int(t);
    if(index < 0 || index >= 2) index = 0;
    return SizeType_strings[index];
}

std::string
LineGlyphAttributes::SizeType_ToString(int t)
{
    int index = (t < 0 || t >= 2) ? 0 : t;
    return SizeType_strings[index];
}

bool
LineGlyphAttributes::SizeType_FromString(const std::string &s, LineGlyphAttributes::SizeType &val)
{
    val = LineGlyphAttributes::Absolute;
    for(int i = 0; i < 2; ++i)
    {
        if(s == SizeType_strings[i])
        {
            val = (SizeType)i;
            return true;
        }
    }
    return false;
}

// ****************************************************************************
// Method: LineGlyphAttributes::LineGlyphAttributes
//
// Purpose:
//   Init utility for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

void LineGlyphAttributes::Init()
{
    lineType = Line;
    lineWidth = 0;
    tubeResolution = 10;
    tubeRadiusSizeType = FractionOfBBox;
    tubeRadiusAbsolute = 0.125;
    tubeRadiusBBox = 0.005;
    tubeRadiusVarEnabled = false;
    tubeRadiusVarRatio = 10;
    tailStyle = None;
    headStyle = None;
    endPointRadiusSizeType = FractionOfBBox;
    endPointRadiusAbsolute = 0.125;
    endPointRadiusBBox = 0.05;
    endPointResolution = 10;
    endPointRatio = 5;
    endPointRadiusVarEnabled = false;
    endPointRadiusVarRatio = 10;

    LineGlyphAttributes::SelectAll();
}

// ****************************************************************************
// Method: LineGlyphAttributes::LineGlyphAttributes
//
// Purpose:
//   Copy utility for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

void LineGlyphAttributes::Copy(const LineGlyphAttributes &obj)
{
    lineType = obj.lineType;
    lineWidth = obj.lineWidth;
    tubeResolution = obj.tubeResolution;
    tubeRadiusSizeType = obj.tubeRadiusSizeType;
    tubeRadiusAbsolute = obj.tubeRadiusAbsolute;
    tubeRadiusBBox = obj.tubeRadiusBBox;
    tubeRadiusVarEnabled = obj.tubeRadiusVarEnabled;
    tubeRadiusVar = obj.tubeRadiusVar;
    tubeRadiusVarRatio = obj.tubeRadiusVarRatio;
    tailStyle = obj.tailStyle;
    headStyle = obj.headStyle;
    endPointRadiusSizeType = obj.endPointRadiusSizeType;
    endPointRadiusAbsolute = obj.endPointRadiusAbsolute;
    endPointRadiusBBox = obj.endPointRadiusBBox;
    endPointResolution = obj.endPointResolution;
    endPointRatio = obj.endPointRatio;
    endPointRadiusVarEnabled = obj.endPointRadiusVarEnabled;
    endPointRadiusVar = obj.endPointRadiusVar;
    endPointRadiusVarRatio = obj.endPointRadiusVarRatio;

    LineGlyphAttributes::SelectAll();
}

// Type map format string
const char *LineGlyphAttributes::TypeMapFormatString = LINEGLYPHATTRIBUTES_TMFS;
const AttributeGroup::private_tmfs_t LineGlyphAttributes::TmfsStruct = {LINEGLYPHATTRIBUTES_TMFS};


// ****************************************************************************
// Method: LineGlyphAttributes::LineGlyphAttributes
//
// Purpose:
//   Default constructor for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

LineGlyphAttributes::LineGlyphAttributes() :
    AttributeSubject(LineGlyphAttributes::TypeMapFormatString),
    tubeRadiusVar("default"), endPointRadiusVar("default")
{
    LineGlyphAttributes::Init();
}

// ****************************************************************************
// Method: LineGlyphAttributes::LineGlyphAttributes
//
// Purpose:
//   Constructor for the derived classes of LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

LineGlyphAttributes::LineGlyphAttributes(private_tmfs_t tmfs) :
    AttributeSubject(tmfs.tmfs),
    tubeRadiusVar("default"), endPointRadiusVar("default")
{
    LineGlyphAttributes::Init();
}

// ****************************************************************************
// Method: LineGlyphAttributes::LineGlyphAttributes
//
// Purpose:
//   Copy constructor for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

LineGlyphAttributes::LineGlyphAttributes(const LineGlyphAttributes &obj) :
    AttributeSubject(LineGlyphAttributes::TypeMapFormatString)
{
    LineGlyphAttributes::Copy(obj);
}

// ****************************************************************************
// Method: LineGlyphAttributes::LineGlyphAttributes
//
// Purpose:
//   Copy constructor for derived classes of the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

LineGlyphAttributes::LineGlyphAttributes(const LineGlyphAttributes &obj, private_tmfs_t tmfs) :
    AttributeSubject(tmfs.tmfs)
{
    LineGlyphAttributes::Copy(obj);
}

// ****************************************************************************
// Method: LineGlyphAttributes::~LineGlyphAttributes
//
// Purpose:
//   Destructor for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

LineGlyphAttributes::~LineGlyphAttributes()
{
    // nothing here
}

// ****************************************************************************
// Method: LineGlyphAttributes::operator =
//
// Purpose:
//   Assignment operator for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

LineGlyphAttributes&
LineGlyphAttributes::operator = (const LineGlyphAttributes &obj)
{
    if (this == &obj) return *this;

    LineGlyphAttributes::Copy(obj);

    return *this;
}

// ****************************************************************************
// Method: LineGlyphAttributes::operator ==
//
// Purpose:
//   Comparison operator == for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
LineGlyphAttributes::operator == (const LineGlyphAttributes &obj) const
{
    // Create the return value
    return ((lineType == obj.lineType) &&
            (lineWidth == obj.lineWidth) &&
            (tubeResolution == obj.tubeResolution) &&
            (tubeRadiusSizeType == obj.tubeRadiusSizeType) &&
            (tubeRadiusAbsolute == obj.tubeRadiusAbsolute) &&
            (tubeRadiusBBox == obj.tubeRadiusBBox) &&
            (tubeRadiusVarEnabled == obj.tubeRadiusVarEnabled) &&
            (tubeRadiusVar == obj.tubeRadiusVar) &&
            (tubeRadiusVarRatio == obj.tubeRadiusVarRatio) &&
            (tailStyle == obj.tailStyle) &&
            (headStyle == obj.headStyle) &&
            (endPointRadiusSizeType == obj.endPointRadiusSizeType) &&
            (endPointRadiusAbsolute == obj.endPointRadiusAbsolute) &&
            (endPointRadiusBBox == obj.endPointRadiusBBox) &&
            (endPointResolution == obj.endPointResolution) &&
            (endPointRatio == obj.endPointRatio) &&
            (endPointRadiusVarEnabled == obj.endPointRadiusVarEnabled) &&
            (endPointRadiusVar == obj.endPointRadiusVar) &&
            (endPointRadiusVarRatio == obj.endPointRadiusVarRatio));
}

// ****************************************************************************
// Method: LineGlyphAttributes::operator !=
//
// Purpose:
//   Comparison operator != for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
LineGlyphAttributes::operator != (const LineGlyphAttributes &obj) const
{
    return !(this->operator == (obj));
}

// ****************************************************************************
// Method: LineGlyphAttributes::TypeName
//
// Purpose:
//   Type name method for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

const std::string
LineGlyphAttributes::TypeName() const
{
    return "LineGlyphAttributes";
}

// ****************************************************************************
// Method: LineGlyphAttributes::CopyAttributes
//
// Purpose:
//   CopyAttributes method for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
LineGlyphAttributes::CopyAttributes(const AttributeGroup *atts)
{
    if(TypeName() != atts->TypeName())
        return false;

    // Call assignment operator.
    const LineGlyphAttributes *tmp = (const LineGlyphAttributes *)atts;
    *this = *tmp;

    return true;
}

// ****************************************************************************
// Method: LineGlyphAttributes::CreateCompatible
//
// Purpose:
//   CreateCompatible method for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

AttributeSubject *
LineGlyphAttributes::CreateCompatible(const std::string &tname) const
{
    AttributeSubject *retval = 0;
    if(TypeName() == tname)
        retval = new LineGlyphAttributes(*this);
    // Other cases could go here too.

    return retval;
}

// ****************************************************************************
// Method: LineGlyphAttributes::NewInstance
//
// Purpose:
//   NewInstance method for the LineGlyphAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

AttributeSubject *
LineGlyphAttributes::NewInstance(bool copy) const
{
    AttributeSubject *retval = 0;
    if(copy)
        retval = new LineGlyphAttributes(*this);
    else
        retval = new LineGlyphAttributes;

    return retval;
}

// ****************************************************************************
// Method: LineGlyphAttributes::SelectAll
//
// Purpose:
//   Selects all attributes.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

void
LineGlyphAttributes::SelectAll()
{
    Select(ID_lineType,                 (void *)&lineType);
    Select(ID_lineWidth,                (void *)&lineWidth);
    Select(ID_tubeResolution,           (void *)&tubeResolution);
    Select(ID_tubeRadiusSizeType,       (void *)&tubeRadiusSizeType);
    Select(ID_tubeRadiusAbsolute,       (void *)&tubeRadiusAbsolute);
    Select(ID_tubeRadiusBBox,           (void *)&tubeRadiusBBox);
    Select(ID_tubeRadiusVarEnabled,     (void *)&tubeRadiusVarEnabled);
    Select(ID_tubeRadiusVar,            (void *)&tubeRadiusVar);
    Select(ID_tubeRadiusVarRatio,       (void *)&tubeRadiusVarRatio);
    Select(ID_tailStyle,                (void *)&tailStyle);
    Select(ID_headStyle,                (void *)&headStyle);
    Select(ID_endPointRadiusSizeType,   (void *)&endPointRadiusSizeType);
    Select(ID_endPointRadiusAbsolute,   (void *)&endPointRadiusAbsolute);
    Select(ID_endPointRadiusBBox,       (void *)&endPointRadiusBBox);
    Select(ID_endPointResolution,       (void *)&endPointResolution);
    Select(ID_endPointRatio,            (void *)&endPointRatio);
    Select(ID_endPointRadiusVarEnabled, (void *)&endPointRadiusVarEnabled);
    Select(ID_endPointRadiusVar,        (void *)&endPointRadiusVar);
    Select(ID_endPointRadiusVarRatio,   (void *)&endPointRadiusVarRatio);
}

///////////////////////////////////////////////////////////////////////////////
// Persistence methods
///////////////////////////////////////////////////////////////////////////////

// ****************************************************************************
// Method: LineGlyphAttributes::CreateNode
//
// Purpose:
//   This method creates a DataNode representation of the object so it can be saved to a config file.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
LineGlyphAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    LineGlyphAttributes defaultObject;
    bool addToParent = false;
    // Create a node for LineGlyphAttributes.
    DataNode *node = new DataNode("LineGlyphAttributes");

    if(completeSave || !FieldsEqual(ID_lineType, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("lineType", LineType_ToString(lineType)));
    }

    if(completeSave || !FieldsEqual(ID_lineWidth, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("lineWidth", lineWidth));
    }

    if(completeSave || !FieldsEqual(ID_tubeResolution, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("tubeResolution", tubeResolution));
    }

    if(completeSave || !FieldsEqual(ID_tubeRadiusSizeType, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("tubeRadiusSizeType", SizeType_ToString(tubeRadiusSizeType)));
    }

    if(completeSave || !FieldsEqual(ID_tubeRadiusAbsolute, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("tubeRadiusAbsolute", tubeRadiusAbsolute));
    }

    if(completeSave || !FieldsEqual(ID_tubeRadiusBBox, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("tubeRadiusBBox", tubeRadiusBBox));
    }

    if(completeSave || !FieldsEqual(ID_tubeRadiusVarEnabled, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("tubeRadiusVarEnabled", tubeRadiusVarEnabled));
    }

    if(completeSave || !FieldsEqual(ID_tubeRadiusVar, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("tubeRadiusVar", tubeRadiusVar));
    }

    if(completeSave || !FieldsEqual(ID_tubeRadiusVarRatio, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("tubeRadiusVarRatio", tubeRadiusVarRatio));
    }

    if(completeSave || !FieldsEqual(ID_tailStyle, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("tailStyle", EndPointStyle_ToString(tailStyle)));
    }

    if(completeSave || !FieldsEqual(ID_headStyle, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("headStyle", EndPointStyle_ToString(headStyle)));
    }

    if(completeSave || !FieldsEqual(ID_endPointRadiusSizeType, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("endPointRadiusSizeType", SizeType_ToString(endPointRadiusSizeType)));
    }

    if(completeSave || !FieldsEqual(ID_endPointRadiusAbsolute, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("endPointRadiusAbsolute", endPointRadiusAbsolute));
    }

    if(completeSave || !FieldsEqual(ID_endPointRadiusBBox, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("endPointRadiusBBox", endPointRadiusBBox));
    }

    if(completeSave || !FieldsEqual(ID_endPointResolution, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("endPointResolution", endPointResolution));
    }

    if(completeSave || !FieldsEqual(ID_endPointRatio, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("endPointRatio", endPointRatio));
    }

    if(completeSave || !FieldsEqual(ID_endPointRadiusVarEnabled, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("endPointRadiusVarEnabled", endPointRadiusVarEnabled));
    }

    if(completeSave || !FieldsEqual(ID_endPointRadiusVar, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("endPointRadiusVar", endPointRadiusVar));
    }

    if(completeSave || !FieldsEqual(ID_endPointRadiusVarRatio, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("endPointRadiusVarRatio", endPointRadiusVarRatio));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}

// ****************************************************************************
// Method: LineGlyphAttributes::SetFromNode
//
// Purpose:
//   This method sets attributes in this object from values in a DataNode representation of the object.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

void
LineGlyphAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("LineGlyphAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("lineType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetLineType(LineType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            LineType value;
            if(LineType_FromString(node->AsString(), value))
                SetLineType(value);
        }
    }
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("tubeResolution")) != 0)
        SetTubeResolution(node->AsInt());
    if((node = searchNode->GetNode("tubeRadiusSizeType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetTubeRadiusSizeType(SizeType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            SizeType value;
            if(SizeType_FromString(node->AsString(), value))
                SetTubeRadiusSizeType(value);
        }
    }
    if((node = searchNode->GetNode("tubeRadiusAbsolute")) != 0)
        SetTubeRadiusAbsolute(node->AsDouble());
    if((node = searchNode->GetNode("tubeRadiusBBox")) != 0)
        SetTubeRadiusBBox(node->AsDouble());
    if((node = searchNode->GetNode("tubeRadiusVarEnabled")) != 0)
        SetTubeRadiusVarEnabled(node->AsBool());
    if((node = searchNode->GetNode("tubeRadiusVar")) != 0)
        SetTubeRadiusVar(node->AsString());
    if((node = searchNode->GetNode("tubeRadiusVarRatio")) != 0)
        SetTubeRadiusVarRatio(node->AsDouble());
    if((node = searchNode->GetNode("tailStyle")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetTailStyle(EndPointStyle(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            EndPointStyle value;
            if(EndPointStyle_FromString(node->AsString(), value))
                SetTailStyle(value);
        }
    }
    if((node = searchNode->GetNode("headStyle")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetHeadStyle(EndPointStyle(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            EndPointStyle value;
            if(EndPointStyle_FromString(node->AsString(), value))
                SetHeadStyle(value);
        }
    }
    if((node = searchNode->GetNode("endPointRadiusSizeType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetEndPointRadiusSizeType(SizeType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            SizeType value;
            if(SizeType_FromString(node->AsString(), value))
                SetEndPointRadiusSizeType(value);
        }
    }
    if((node = searchNode->GetNode("endPointRadiusAbsolute")) != 0)
        SetEndPointRadiusAbsolute(node->AsDouble());
    if((node = searchNode->GetNode("endPointRadiusBBox")) != 0)
        SetEndPointRadiusBBox(node->AsDouble());
    if((node = searchNode->GetNode("endPointResolution")) != 0)
        SetEndPointResolution(node->AsInt());
    if((node = searchNode->GetNode("endPointRatio")) != 0)
        SetEndPointRatio(node->AsDouble());
    if((node = searchNode->GetNode("endPointRadiusVarEnabled")) != 0)
        SetEndPointRadiusVarEnabled(node->AsBool());
    if((node = searchNode->GetNode("endPointRadiusVar")) != 0)
        SetEndPointRadiusVar(node->AsString());
    if((node = searchNode->GetNode("endPointRadiusVarRatio")) != 0)
        SetEndPointRadiusVarRatio(node->AsDouble());
}

///////////////////////////////////////////////////////////////////////////////
// Set property methods
///////////////////////////////////////////////////////////////////////////////

void
LineGlyphAttributes::SetLineType(LineGlyphAttributes::LineType lineType_)
{
    lineType = lineType_;
    Select(ID_lineType, (void *)&lineType);
}

void
LineGlyphAttributes::SetLineWidth(int lineWidth_)
{
    lineWidth = lineWidth_;
    Select(ID_lineWidth, (void *)&lineWidth);
}

void
LineGlyphAttributes::SetTubeResolution(int tubeResolution_)
{
    tubeResolution = tubeResolution_;
    Select(ID_tubeResolution, (void *)&tubeResolution);
}

void
LineGlyphAttributes::SetTubeRadiusSizeType(LineGlyphAttributes::SizeType tubeRadiusSizeType_)
{
    tubeRadiusSizeType = tubeRadiusSizeType_;
    Select(ID_tubeRadiusSizeType, (void *)&tubeRadiusSizeType);
}

void
LineGlyphAttributes::SetTubeRadiusAbsolute(double tubeRadiusAbsolute_)
{
    tubeRadiusAbsolute = tubeRadiusAbsolute_;
    Select(ID_tubeRadiusAbsolute, (void *)&tubeRadiusAbsolute);
}

void
LineGlyphAttributes::SetTubeRadiusBBox(double tubeRadiusBBox_)
{
    tubeRadiusBBox = tubeRadiusBBox_;
    Select(ID_tubeRadiusBBox, (void *)&tubeRadiusBBox);
}

void
LineGlyphAttributes::SetTubeRadiusVarEnabled(bool tubeRadiusVarEnabled_)
{
    tubeRadiusVarEnabled = tubeRadiusVarEnabled_;
    Select(ID_tubeRadiusVarEnabled, (void *)&tubeRadiusVarEnabled);
}

void
LineGlyphAttributes::SetTubeRadiusVar(const std::string &tubeRadiusVar_)
{
    tubeRadiusVar = tubeRadiusVar_;
    Select(ID_tubeRadiusVar, (void *)&tubeRadiusVar);
}

void
LineGlyphAttributes::SetTubeRadiusVarRatio(double tubeRadiusVarRatio_)
{
    tubeRadiusVarRatio = tubeRadiusVarRatio_;
    Select(ID_tubeRadiusVarRatio, (void *)&tubeRadiusVarRatio);
}

void
LineGlyphAttributes::SetTailStyle(LineGlyphAttributes::EndPointStyle tailStyle_)
{
    tailStyle = tailStyle_;
    Select(ID_tailStyle, (void *)&tailStyle);
}

void
LineGlyphAttributes::SetHeadStyle(LineGlyphAttributes::EndPointStyle headStyle_)
{
    headStyle = headStyle_;
    Select(ID_headStyle, (void *)&headStyle);
}

void
LineGlyphAttributes::SetEndPointRadiusSizeType(LineGlyphAttributes::SizeType endPointRadiusSizeType_)
{
    endPointRadiusSizeType = endPointRadiusSizeType_;
    Select(ID_endPointRadiusSizeType, (void *)&endPointRadiusSizeType);
}

void
LineGlyphAttributes::SetEndPointRadiusAbsolute(double endPointRadiusAbsolute_)
{
    endPointRadiusAbsolute = endPointRadiusAbsolute_;
    Select(ID_endPointRadiusAbsolute, (void *)&endPointRadiusAbsolute);
}

void
LineGlyphAttributes::SetEndPointRadiusBBox(double endPointRadiusBBox_)
{
    endPointRadiusBBox = endPointRadiusBBox_;
    Select(ID_endPointRadiusBBox, (void *)&endPointRadiusBBox);
}

void
LineGlyphAttributes::SetEndPointResolution(int endPointResolution_)
{
    endPointResolution = endPointResolution_;
    Select(ID_endPointResolution, (void *)&endPointResolution);
}

void
LineGlyphAttributes::SetEndPointRatio(double endPointRatio_)
{
    endPointRatio = endPointRatio_;
    Select(ID_endPointRatio, (void *)&endPointRatio);
}

void
LineGlyphAttributes::SetEndPointRadiusVarEnabled(bool endPointRadiusVarEnabled_)
{
    endPointRadiusVarEnabled = endPointRadiusVarEnabled_;
    Select(ID_endPointRadiusVarEnabled, (void *)&endPointRadiusVarEnabled);
}

void
LineGlyphAttributes::SetEndPointRadiusVar(const std::string &endPointRadiusVar_)
{
    endPointRadiusVar = endPointRadiusVar_;
    Select(ID_endPointRadiusVar, (void *)&endPointRadiusVar);
}

void
LineGlyphAttributes::SetEndPointRadiusVarRatio(double endPointRadiusVarRatio_)
{
    endPointRadiusVarRatio = endPointRadiusVarRatio_;
    Select(ID_endPointRadiusVarRatio, (void *)&endPointRadiusVarRatio);
}

///////////////////////////////////////////////////////////////////////////////
// Get property methods
///////////////////////////////////////////////////////////////////////////////

LineGlyphAttributes::LineType
LineGlyphAttributes::GetLineType() const
{
    return LineType(lineType);
}

int
LineGlyphAttributes::GetLineWidth() const
{
    return lineWidth;
}

int
LineGlyphAttributes::GetTubeResolution() const
{
    return tubeResolution;
}

LineGlyphAttributes::SizeType
LineGlyphAttributes::GetTubeRadiusSizeType() const
{
    return SizeType(tubeRadiusSizeType);
}

double
LineGlyphAttributes::GetTubeRadiusAbsolute() const
{
    return tubeRadiusAbsolute;
}

double
LineGlyphAttributes::GetTubeRadiusBBox() const
{
    return tubeRadiusBBox;
}

bool
LineGlyphAttributes::GetTubeRadiusVarEnabled() const
{
    return tubeRadiusVarEnabled;
}

const std::string &
LineGlyphAttributes::GetTubeRadiusVar() const
{
    return tubeRadiusVar;
}

std::string &
LineGlyphAttributes::GetTubeRadiusVar()
{
    return tubeRadiusVar;
}

double
LineGlyphAttributes::GetTubeRadiusVarRatio() const
{
    return tubeRadiusVarRatio;
}

LineGlyphAttributes::EndPointStyle
LineGlyphAttributes::GetTailStyle() const
{
    return EndPointStyle(tailStyle);
}

LineGlyphAttributes::EndPointStyle
LineGlyphAttributes::GetHeadStyle() const
{
    return EndPointStyle(headStyle);
}

LineGlyphAttributes::SizeType
LineGlyphAttributes::GetEndPointRadiusSizeType() const
{
    return SizeType(endPointRadiusSizeType);
}

double
LineGlyphAttributes::GetEndPointRadiusAbsolute() const
{
    return endPointRadiusAbsolute;
}

double
LineGlyphAttributes::GetEndPointRadiusBBox() const
{
    return endPointRadiusBBox;
}

int
LineGlyphAttributes::GetEndPointResolution() const
{
    return endPointResolution;
}

double
LineGlyphAttributes::GetEndPointRatio() const
{
    return endPointRatio;
}

bool
LineGlyphAttributes::GetEndPointRadiusVarEnabled() const
{
    return endPointRadiusVarEnabled;
}

const std::string &
LineGlyphAttributes::GetEndPointRadiusVar() const
{
    return endPointRadiusVar;
}

std::string &
LineGlyphAttributes::GetEndPointRadiusVar()
{
    return endPointRadiusVar;
}

double
LineGlyphAttributes::GetEndPointRadiusVarRatio() const
{
    return endPointRadiusVarRatio;
}

///////////////////////////////////////////////////////////////////////////////
// Select property methods
///////////////////////////////////////////////////////////////////////////////

void
LineGlyphAttributes::SelectTubeRadiusVar()
{
    Select(ID_tubeRadiusVar, (void *)&tubeRadiusVar);
}

void
LineGlyphAttributes::SelectEndPointRadiusVar()
{
    Select(ID_endPointRadiusVar, (void *)&endPointRadiusVar);
}

///////////////////////////////////////////////////////////////////////////////
// Keyframing methods
///////////////////////////////////////////////////////////////////////////////

// ****************************************************************************
// Method: LineGlyphAttributes::GetFieldName
//
// Purpose:
//   This method returns the name of a field given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

std::string
LineGlyphAttributes::GetFieldName(int index) const
{
    switch (index)
    {
    case ID_lineType:                 return "lineType";
    case ID_lineWidth:                return "lineWidth";
    case ID_tubeResolution:           return "tubeResolution";
    case ID_tubeRadiusSizeType:       return "tubeRadiusSizeType";
    case ID_tubeRadiusAbsolute:       return "tubeRadiusAbsolute";
    case ID_tubeRadiusBBox:           return "tubeRadiusBBox";
    case ID_tubeRadiusVarEnabled:     return "tubeRadiusVarEnabled";
    case ID_tubeRadiusVar:            return "tubeRadiusVar";
    case ID_tubeRadiusVarRatio:       return "tubeRadiusVarRatio";
    case ID_tailStyle:                return "tailStyle";
    case ID_headStyle:                return "headStyle";
    case ID_endPointRadiusSizeType:   return "endPointRadiusSizeType";
    case ID_endPointRadiusAbsolute:   return "endPointRadiusAbsolute";
    case ID_endPointRadiusBBox:       return "endPointRadiusBBox";
    case ID_endPointResolution:       return "endPointResolution";
    case ID_endPointRatio:            return "endPointRatio";
    case ID_endPointRadiusVarEnabled: return "endPointRadiusVarEnabled";
    case ID_endPointRadiusVar:        return "endPointRadiusVar";
    case ID_endPointRadiusVarRatio:   return "endPointRadiusVarRatio";
    default:  return "invalid index";
    }
}

// ****************************************************************************
// Method: LineGlyphAttributes::GetFieldType
//
// Purpose:
//   This method returns the type of a field given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

AttributeGroup::FieldType
LineGlyphAttributes::GetFieldType(int index) const
{
    switch (index)
    {
    case ID_lineType:                 return FieldType_enum;
    case ID_lineWidth:                return FieldType_linewidth;
    case ID_tubeResolution:           return FieldType_int;
    case ID_tubeRadiusSizeType:       return FieldType_enum;
    case ID_tubeRadiusAbsolute:       return FieldType_double;
    case ID_tubeRadiusBBox:           return FieldType_double;
    case ID_tubeRadiusVarEnabled:     return FieldType_bool;
    case ID_tubeRadiusVar:            return FieldType_variablename;
    case ID_tubeRadiusVarRatio:       return FieldType_double;
    case ID_tailStyle:                return FieldType_enum;
    case ID_headStyle:                return FieldType_enum;
    case ID_endPointRadiusSizeType:   return FieldType_enum;
    case ID_endPointRadiusAbsolute:   return FieldType_double;
    case ID_endPointRadiusBBox:       return FieldType_double;
    case ID_endPointResolution:       return FieldType_int;
    case ID_endPointRatio:            return FieldType_double;
    case ID_endPointRadiusVarEnabled: return FieldType_bool;
    case ID_endPointRadiusVar:        return FieldType_variablename;
    case ID_endPointRadiusVarRatio:   return FieldType_double;
    default:  return FieldType_unknown;
    }
}

// ****************************************************************************
// Method: LineGlyphAttributes::GetFieldTypeName
//
// Purpose:
//   This method returns the name of a field type given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

std::string
LineGlyphAttributes::GetFieldTypeName(int index) const
{
    switch (index)
    {
    case ID_lineType:                 return "enum";
    case ID_lineWidth:                return "linewidth";
    case ID_tubeResolution:           return "int";
    case ID_tubeRadiusSizeType:       return "enum";
    case ID_tubeRadiusAbsolute:       return "double";
    case ID_tubeRadiusBBox:           return "double";
    case ID_tubeRadiusVarEnabled:     return "bool";
    case ID_tubeRadiusVar:            return "variablename";
    case ID_tubeRadiusVarRatio:       return "double";
    case ID_tailStyle:                return "enum";
    case ID_headStyle:                return "enum";
    case ID_endPointRadiusSizeType:   return "enum";
    case ID_endPointRadiusAbsolute:   return "double";
    case ID_endPointRadiusBBox:       return "double";
    case ID_endPointResolution:       return "int";
    case ID_endPointRatio:            return "double";
    case ID_endPointRadiusVarEnabled: return "bool";
    case ID_endPointRadiusVar:        return "variablename";
    case ID_endPointRadiusVarRatio:   return "double";
    default:  return "invalid index";
    }
}

// ****************************************************************************
// Method: LineGlyphAttributes::FieldsEqual
//
// Purpose:
//   This method compares two fields and return true if they are equal.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   omitted
//
// Modifications:
//
// ****************************************************************************

bool
LineGlyphAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
{
    const LineGlyphAttributes &obj = *((const LineGlyphAttributes*)rhs);
    bool retval = false;
    switch (index_)
    {
    case ID_lineType:
        {  // new scope
        retval = (lineType == obj.lineType);
        }
        break;
    case ID_lineWidth:
        {  // new scope
        retval = (lineWidth == obj.lineWidth);
        }
        break;
    case ID_tubeResolution:
        {  // new scope
        retval = (tubeResolution == obj.tubeResolution);
        }
        break;
    case ID_tubeRadiusSizeType:
        {  // new scope
        retval = (tubeRadiusSizeType == obj.tubeRadiusSizeType);
        }
        break;
    case ID_tubeRadiusAbsolute:
        {  // new scope
        retval = (tubeRadiusAbsolute == obj.tubeRadiusAbsolute);
        }
        break;
    case ID_tubeRadiusBBox:
        {  // new scope
        retval = (tubeRadiusBBox == obj.tubeRadiusBBox);
        }
        break;
    case ID_tubeRadiusVarEnabled:
        {  // new scope
        retval = (tubeRadiusVarEnabled == obj.tubeRadiusVarEnabled);
        }
        break;
    case ID_tubeRadiusVar:
        {  // new scope
        retval = (tubeRadiusVar == obj.tubeRadiusVar);
        }
        break;
    case ID_tubeRadiusVarRatio:
        {  // new scope
        retval = (tubeRadiusVarRatio == obj.tubeRadiusVarRatio);
        }
        break;
    case ID_tailStyle:
        {  // new scope
        retval = (tailStyle == obj.tailStyle);
        }
        break;
    case ID_headStyle:
        {  // new scope
        retval = (headStyle == obj.headStyle);
        }
        break;
    case ID_endPointRadiusSizeType:
        {  // new scope
        retval = (endPointRadiusSizeType == obj.endPointRadiusSizeType);
        }
        break;
    case ID_endPointRadiusAbsolute:
        {  // new scope
        retval = (endPointRadiusAbsolute == obj.endPointRadiusAbsolute);
        }
        break;
    case ID_endPointRadiusBBox:
        {  // new scope
        retval = (endPointRadiusBBox == obj.endPointRadiusBBox);
        }
        break;
    case ID_endPointResolution:
        {  // new scope
        retval = (endPointResolution == obj.endPointResolution);
        }
        break;
    case ID_endPointRatio:
        {  // new scope
        retval = (endPointRatio == obj.endPointRatio);
        }
        break;
    case ID_endPointRadiusVarEnabled:
        {  // new scope
        retval = (endPointRadiusVarEnabled == obj.endPointRadiusVarEnabled);
        }
        break;
    case ID_endPointRadiusVar:
        {  // new scope
        retval = (endPointRadiusVar == obj.endPointRadiusVar);
        }
        break;
    case ID_endPointRadiusVarRatio:
        {  // new scope
        retval = (endPointRadiusVarRatio == obj.endPointRadiusVarRatio);
        }
        break;
    default: retval = false;
    }

    return retval;
}

///////////////////////////////////////////////////////////////////////////////
// User-defined methods.
///////////////////////////////////////////////////////////////////////////////

// ****************************************************************************
// Modifications:
//
// ****************************************************************************
bool
LineGlyphAttributes::ChangesRequireRecalculation(const LineGlyphAttributes &obj) const
{
   bool needSecondaryVar = (obj.lineType == Tube &&
                            obj.tubeRadiusVarEnabled &&
                            obj.tubeRadiusVar != tubeRadiusVar &&
                            obj.tubeRadiusVar != "default" &&
                            obj.tubeRadiusVar != "" &&
                            obj.tubeRadiusVar != "\0") ||

                           ((obj.tailStyle != None ||
                             obj.headStyle != None) &&
                            obj.endPointRadiusVarEnabled &&
                            obj.endPointRadiusVar != endPointRadiusVar &&
                            obj.endPointRadiusVar != "default" &&
                            obj.endPointRadiusVar != "" &&
                            obj.endPointRadiusVar != "\0");


    bool geometryChange =  (lineType             != obj.lineType ||
                            tubeRadiusSizeType   != obj.tubeRadiusSizeType ||
                            tubeRadiusAbsolute   != obj.tubeRadiusAbsolute ||
                            tubeRadiusBBox       != obj.tubeRadiusBBox ||
                            tubeRadiusVarEnabled != obj.tubeRadiusVarEnabled ||
                            tubeRadiusVar        != obj.tubeRadiusVar ||
                            tubeRadiusVarRatio   != obj.tubeRadiusVarRatio ||
                            tubeResolution       != obj.tubeResolution ||

                            tailStyle                != obj.tailStyle ||
                            headStyle                != obj.headStyle ||
                            endPointRatio            != obj.endPointRatio ||
                            endPointRadiusSizeType   != obj.endPointRadiusSizeType ||
                            endPointRadiusAbsolute   != obj.endPointRadiusAbsolute ||
                            endPointRadiusBBox       != obj.endPointRadiusBBox ||
                            endPointRadiusVarEnabled != obj.endPointRadiusVarEnabled ||
                            endPointRadiusVar        != obj.endPointRadiusVar ||
                            endPointRadiusVarRatio   != obj.endPointRadiusVarRatio ||
                            endPointResolution       != obj.endPointResolution);

    return needSecondaryVar || geometryChange;
}

